let papScript=document.createElement('script');papScript.id='pap_x2s6df8d';papScript.type='text/javascript'; papScript.src=(('https:' == document.location.protocol)?'https://':'http://')+'affiliates.baaboo.com/scripts/kafj4d'; papScript.onload = doIfYouCan(); document.body.appendChild(papScript); function ts() { var discountcoupon = ''; if (Shopify.checkout.discount != null && typeof Shopify.checkout.discount.code !== 'undefined') { discountcoupon = Shopify.checkout.discount.code; } var giftcard = 0; if ((typeof Shopify.checkout.gift_cards !== 'undefined') && (Shopify.checkout.gift_cards.length > 0) ) { for (var i=0; i < Shopify.checkout.gift_cards.length; i++) { if (Shopify.checkout.gift_cards[i].amount_used > 0) { giftcard += Number(Shopify.checkout.gift_cards[i].amount_used); } } } var papPhone = Shopify.checkout.phone; if (papPhone == null || papPhone == '') { papPhone = Shopify.checkout.billing_address.phone; } var item = 0; while (typeof Shopify.checkout.line_items[item] !== 'undefined') { var subtotal = Shopify.checkout.line_items[item].line_price.replace(',',''); var di = 0; while (typeof Shopify.checkout.line_items[item].discount_allocations[di] !== 'undefined') { subtotal -= Shopify.checkout.line_items[item].discount_allocations[di].amount; di++; } if (giftcard > 0 && subtotal > 0) {var rest = giftcard - subtotal; subtotal = subtotal - giftcard;} if (typeof rest === 'number') { giftcard = rest.toFixed(2); } if (giftcard < 0) {giftcard = 0} if (typeof Shopify.checkout.taxes_included !== 'undefined' && Shopify.checkout.taxes_included === true && typeof Shopify.checkout.line_items[item].taxable !== 'undefined' && Shopify.checkout.line_items[item].taxable === true ) { var ti = 0; while (typeof Shopify.checkout.line_items[item].tax_lines[ti] !== 'undefined') { subtotal -= Shopify.checkout.line_items[item].tax_lines[ti].price.replace(',',''); ti++; } }if (subtotal < 0) {subtotal = 0} var sale = PostAffTracker.createSale(); sale.setTotalCost(subtotal); if (Shopify.checkout.order_id == null) { sale.setOrderId('checkout_token_'+Shopify.checkout.token+'('+(item+1)+')'); } else { sale.setOrderId(Shopify.checkout.order_id+'('+(item+1)+')'); } if (typeof Shopify.checkout.presentment_currency !== 'undefined') { sale.setCurrency(Shopify.checkout.presentment_currency); } else { sale.setCurrency(Shopify.checkout.currency); } var papProductId = Shopify.checkout.line_items[item].sku; if (papProductId == '') {papProductId = Shopify.checkout.line_items[item].product_id;} sale.setProductId(papProductId);var papD1 = Shopify.checkout.email; if (papD1 != null && typeof papD1 !== 'undefined') {sale.setData1(papD1);} var papD2 = Shopify.checkout.line_items[item].sku; if (papD2 != null && typeof papD2 !== 'undefined') {sale.setData2(papD2);} var papD3 = Shopify.checkout.line_items[item].price; if (papD3 != null && typeof papD3 !== 'undefined') {sale.setData3(papD3);} var papD4 = Shopify.checkout.line_items[item].quantity; if (papD4 != null && typeof papD4 !== 'undefined') {sale.setData4(papD4);} var papD5 = Shopify.checkout.line_items[item].product_id; if (papD5 != null && typeof papD5 !== 'undefined') {sale.setData5(papD5);} if (Shopify.checkout.line_items.length != (item+1)) { if (typeof sale.doNotDeleteCookies === 'function') {sale.doNotDeleteCookies();} PostAffTracker.register(); } else { if (typeof PostAffTracker.registerOnAllFinished === 'function') { PostAffTracker.registerOnAllFinished(); } else { PostAffTracker.register(); } } item++; } } function doIfYouCan() { if (typeof PostAffTracker !== 'undefined') { PostAffTracker.setAccountId('default1'); if (window.location.href.indexOf('/thank_you') > 0) { ts(); } else { PostAffTracker.executeOnResponseFinished.push(function() { var xhr = new XMLHttpRequest(); xhr.open('POST', '/cart/update.js', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send('attributes[papvisitorid]=' + PostAffTracker.getVisitorId()); }); try { PostAffTracker.track(); } catch (err) { } } } else { setTimeout('doIfYouCan()', 500); } }